//---------------------------------------------------------------------------
/**
 * \class CBufferedLineStream
 * \brief This is a line stream to provide buffered stream by line
 * \version 0.1
 *
 * \author Woo-Hyun Kim (woorung@nhncorp.com, woorung@gmail.com)
 * \author http://blog.naver.com/wisereign .
 *
 * \date 2007/12/05
 */
//---------------------------------------------------------------------------
#ifndef CBufferedLineStreamH
#define CBufferedLineStreamH
//---------------------------------------------------------------------------
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdexcept>
#include <errno.h>

#include "CBufferedStream.h"
//---------------------------------------------------------------------------
#define END_OF_LINE '\n'
//---------------------------------------------------------------------------
using namespace std;
//---------------------------------------------------------------------------
class CBufferedLineStream : public CBufferedStream {
private :
	char eol; // the end of line
	long block;
	long blocks;
	long block_begin_pos;
	long block_end_pos;

    virtual int underflow();

protected :
	CBufferedLineStream(const CBufferedLineStream &rhs);
	CBufferedLineStream &operator=(const CBufferedLineStream &rhs);

public :
	CBufferedLineStream(const char *filename);
	virtual ~CBufferedLineStream();

	virtual void adjusted_line_seekg(long &bpos, long &epos);
	virtual uint64_t seekg(uint64_t pos);
	virtual uint64_t tellg() ;
	virtual uint64_t size() const;

	virtual long assignblock(long block, long blocks);
};
//---------------------------------------------------------------------------
#endif
